import request from '@/utils/request'
// 登录请求
export function login(data) {
  return request({
    // url: '/vue-element-admin/user/login',
    url: '/userManager/user/login/',
    method: 'post',
    // 传入token参数给后台，然后根据这个token获取用户信息
    data: data
  })
}

// 获取用户信息，在这里加上之前或者在后端加入token判断
export function getInfo(token) {
  return request({
    url: '/userManager/user/info/',
    method: 'get',
    // 传入token参数给后台，然后根据这个token获取用户信息
    params: {
      token: token
    }
  })
}

export function logout(token) {
  return request({
    url: '/userManager/user/logout/',
    method: 'post',
    data: {
      token: token
    }
  })
}

export function getUserList(userInfo, queryParams) {
  if (!userInfo) {
    userInfo = '{}'
  }
  return request({
    url: '/userManager/user/getUserList/',
    method: 'get',
    params: {
      userInfo: userInfo,
      queryParams: queryParams
    }
  })
}

export function addUser(userInfo) {
  return request({
    url: '/userManager/user/addUser/',
    method: 'post',
    data: {
      userInfo: userInfo
    }
  })
}

export function getUser(userId) {
  return request({
    url: '/userManager/user/getUser/',
    method: 'post',
    data: {
      userId: userId
    }
  })
}

export function editUser_realName(userInfo) {
  return request({
    url: '/userManager/user/editUser_realName/',
    method: 'post',
    data: {
      userInfo: userInfo
    }
  })
}

export function editUser_password(userInfo) {
  return request({
    url: '/userManager/user/editUser_password/',
    method: 'post',
    data: {
      userInfo: userInfo
    }
  })
}

export function editUser(userInfo) {
  return request({
    url: '/userManager/user/editUser/',
    method: 'post',
    data: {
      userInfo: userInfo
    }
  })
}

export function resetPasswd(userId) {
  return request({
    url: '/userManager/user/resetPassword/',
    method: 'post',
    data: {
      userId: userId
    }
  })
}

export function deleteUser(userId) {
  return request({
    url: '/userManager/user/deleteUser/',
    method: 'post',
    data: {
      userId: userId
    }
  })
}
